package com.example.springbootdemo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: ShengXiaJia
 * @Date: 2019/12/6 16:40
 * @Description: 拦截器配置
 */
// 注意: 1、SpringBoot2.X之前旧版本:继承WebMvcConfigurerAdapter 2、拦截器最后路径一定要 "/**",如果是目录的话则是 "/*/"
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

//        registry.addInterceptor(new MyInterceptor())
//                //需要被拦截的路径
//                .addPathPatterns("/api/*/**")
//                //不需要被拦截的路径
//                .excludePathPatterns("/api/a/**");

        WebMvcConfigurer.super.addInterceptors(registry);
    }

}
